import Cookies from 'js-cookie';

let ROLES = JSON.parse(sessionStorage.getItem('area_cloud_access'))
let area_user_role_tag = parseInt(Cookies.get('area_user_role_tag'))

//广告权限
export const AD_ACCESS = {
    'LIST': 'adlist',
    'ADD': 'adadd',
    'EDIT': 'adedit',
    'DELETE': 'addelete'
}



export const  updateRoles = function () {
    ROLES = JSON.parse(sessionStorage.getItem('area_cloud_access'))
    area_user_role_tag = parseInt(Cookies.get('area_user_role_tag'))
}

export const hasRole = function(module, access) {
    if(area_user_role_tag === 1) {
        return true
    }
    return ROLES.some((r, i) => {
        return r.check_node === module[access]
    });
}

